home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * ConsoleHandler.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS_isModuleInitialized("IS.NOF.UTIL.LOGGING.ConsoleHandler"))
- {
- /****h* NOF_JavaScript_Library/NOF.UTIL.LOGGING.ConsoleHandler
- *
- * NAME
- * NOF.UTIL.LOGGING.ConsoleHandler
- *
- * DESCRIPTION
- * <code>ConsoleHandler</code> is a <code>Handler</code> designed to
- * log messages into a HTML window. It inherits all the methods provided
- * by the Handler class, plus the close() method.
- *
- * var cfgLogger = NOF.UTIL.LOGGING.getLogger("myModuleName");
- * var cHndl = new NOF.UTIL.LOGGING.ConsoleHandler(cfgLogger);
- * cfgLogger.addHandler( cHndl );
- * cfgLogger.warning(" {0} is stronger than {1}! ", "mySourceClass", "mySourceMethod", ["Superman", "Batman"] );
- * // ...
- * try {
- * cHndl.close();
- * } catch (closing_e) {
- * // ...
- * }
- *
- * External dependencies:
- * NOF.IO.TextElementWriter
- *
- ****/
-
- /**
- * constructor
- * Open a new console window (replace existing window with the same name)
- *
- * @param logger instance of the Logger who "owns" this Handler
- **/
- function LOGGING_ConsoleHandler( logger ) {
- this.__proto__ = LOGGING_ConsoleHandler.prototype;
-
- this.SUPER(logger);
-
- var wndHndName = (this.logger != null) ? this.logger.getLoggerName() : "";
- wndHndName = wndHndName.replace(/\./g, "_");
-
- this.wnd = window.open("", wndHndName, "width=670,height=430,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0");
- this.wnd.document.open("text/html");
- this.wnd.document.write(this.CONSOLE_WINDOW_HTML);
- this.wnd.document.close();
- this.wnd.document.title = wndHndName;
-
- this.writer = new NOF.IO.TextElementWriter(this.wnd.document["dbgFrm"].console);
-
- }
- LOGGING_ConsoleHandler.inherits(LOGGING.Handler)
- {
- var member = LOGGING_ConsoleHandler.prototype;
- member.CLASS_NAME = "LOGGING.ConsoleHandler";
-
- member.CONSOLE_WINDOW_HTML = '<html><head><title>logging</title>\
- <link rel="stylesheet" type="text/css" href="../../global.css">\
- <link rel="stylesheet" type="text/css" href="catalog.css">\
- </head>\
- <body>\
- <form name="dbgFrm">\
- <textarea name="console" rows="23" cols="80" scrolling="auto"></textarea>\
- <input type="button" name="clear" value="clear" onclick="this.form.console.value=\'\';">\
- </form>\
- </body>\
- </html>';
-
- var method = LOGGING_ConsoleHandler.prototype;
-
- /**
- * Write the formatted message to the console.
- *
- * @param ft formatted text
- **/
- method.output = function ( /*string*/ ft) {
- this.writer.writeln(ft);
- }
-
- /**
- * Close the console window.
- *
- **/
- method.close = function () {
- try {
- this.wnd.close();
- } catch(e_ignore) {}
- }
- }
-
- LOGGING.__proto__.ConsoleHandler = LOGGING_ConsoleHandler;
- }